package com.jeeplus.modules.work.queue.service;

import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.modules.work.queue.entity.ElectronicMaterialEntity;
import com.jeeplus.modules.work.queue.mapper.electronicMaterialMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
@Slf4j
@Transactional
public class ElectronicMaterialService {
    private final electronicMaterialMapper mapper;
   public Map<String, List<ElectronicMaterialEntity>> getElectronicMaterial(String loginId){
        Map<String, List<ElectronicMaterialEntity>> map=new HashedMap();
        List<ElectronicMaterialEntity> certification = mapper.getElectronicMaterialCertification(loginId);
        List<ElectronicMaterialEntity> ordinary = mapper.getElectronicMaterialOrdinary(loginId);
        map.put("certification",certification);
        map.put("ordinary",ordinary);
        return map;
    }
    public Integer delElectronicMaterial(String id){
      return mapper.delElectronicMaterial(id);
    }
    public Integer setElectronicMaterial(ElectronicMaterialEntity entity){
        return mapper.setElectronicMaterial(entity);
    }


    public Integer  upElectronicMaterial(ElectronicMaterialEntity entity){
        return mapper.upElectronicMaterial(entity);
    }

    public Integer upElectronicOldMaterial(ElectronicMaterialEntity entity){
        if(mapper.delElectronicMaterial(entity.getOldId()) >= 1){
            return mapper.upElectronicMaterial(entity);
        }else{
            return  0;
        }

    }
    public String getURLById(String id){
       return mapper.getURLById(id);
    }
    public int delUserIdcardMaterial(String userId){
        return mapper.delUserIdcardMaterial(userId);
    }
    public int findMaterialNameCheck(String materialName){
        return mapper.findMaterialNameCheck("%"+materialName+"%");
    }
    public int findMaterialNameCount(String materialName,String loginName){
        return mapper.findMaterialNameCount(materialName,loginName);
    }
    public int updateMaterialStatus(String id,int status){
       return mapper.updateMaterialStatus(id,status);
    }

    public int intoYmbcsRemark(String materialsId,String remark,String loginName){
       return mapper.intoYmbcsRemark(materialsId,remark,loginName, DateUtils.getDateTime());
    }
    public List<String> findYmbcsRemark(String loginName){
       return mapper.findYmbcsRemark(loginName);
    }
}
